package org.example.test.domain;

import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.example.domain.strategy.service.armory.IStrategyArmory;
import org.example.domain.strategy.service.armory.IStrategyDispatch;
import org.example.infrastructure.persistent.dao.IStrategyAwardDao;
import org.example.infrastructure.persistent.dao.IStrategyDao;
import org.example.infrastructure.persistent.po.StrategyAward;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@RunWith(SpringRunner.class)
@SpringBootTest
public class StrategyArmoryTest {

    @Resource
    private IStrategyArmory strategyArmory;
    @Resource
    private IStrategyDispatch strategyDispatch;
    @Resource
    private IStrategyAwardDao strategyAwardDao;

    @Test
    public void test_dao(){
        List<StrategyAward> strategyAwards = strategyAwardDao.queryStrategyAwardListByStrategyId(100002L);
        log.info("strategyAwards:{}", JSON.toJSONString(strategyAwards));
    }

    @Before
    public void test_strategyArmory(){
        boolean succuss=strategyArmory.assembleLotteryStrategy(100002L);
        log.info("测试结果{}",succuss);
    }

    /**
     * 策略ID+权重值，从装配到策略中随机获取奖品ID值
     */
    @Test
    public void test_getRandom_ruleWeight(){
        log.info("测试结果:{}-4000配置",strategyDispatch.getRandomAwardId(100002L,"4000:101,102,106"));
    }
    @Test
    public void test_getAssembleRandomVal(){
        log.info("测试结果:{}-奖品ID值",strategyDispatch.getRandomAwardId(100002L));
        log.info("测试结果:{}-奖品ID值",strategyDispatch.getRandomAwardId(100002L));
        log.info("测试结果:{}-奖品ID值",strategyDispatch.getRandomAwardId(100002L));
        log.info("测试结果:{}-奖品ID值",strategyDispatch.getRandomAwardId(100002L));
        log.info("测试结果:{}-奖品ID值",strategyDispatch.getRandomAwardId(100002L));
    }




}
